import 'package:flutter/material.dart';
import 'package:mathfun/utils/responsive_util.dart';
import 'package:mathfun/utils/app_colors.dart';
import 'package:mathfun/components/training_card.dart';
import 'training_history_page.dart';
import 'dot_flash_training_page.dart';

class HomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('数感小达人'),
        actions: [
          IconButton(
            icon: Icon(Icons.settings),
            onPressed: () => Navigator.pushNamed(context, '/settings'),
          ),
        ],
      ),
      body: Padding(
        padding: const EdgeInsets.all(24.0),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Text(
              '请选择训练模式',
              style: TextStyle(fontSize: ResponsiveUtil.fontSize(24), fontWeight: FontWeight.bold),
            ),
            SizedBox(height: 40),
            Column(
              children: [
                // 第一行：点数识别和点数快闪
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                  children: [
                    TrainingCard(
                      title: '点数识别',
                      icon: Icons.gesture,
                      color: AppColors.dotTraining,
                      onPressed: () => Navigator.pushNamed(context, '/dot'),
                    ),
                    SizedBox(width: 20),
                    TrainingCard(
                      title: '点数快闪',
                      icon: Icons.flash_on,
                      color: AppColors.dotFlashTraining,
                      onPressed: () => Navigator.pushNamed(context, '/dot_flash'),
                    ),
                  ],
                ),
                SizedBox(height: 20),
                // 第二行：凑十连连看和听算挑战
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                  children: [
                    TrainingCard(
                      title: '凑十连连看',
                      icon: Icons.grid_on,
                      color: AppColors.makeTenTraining,
                      onPressed: () => Navigator.pushNamed(context, '/make_ten'),
                    ),
                    SizedBox(width: 20),
                    TrainingCard(
                      title: '听算挑战',
                      icon: Icons.headphones,
                      color: AppColors.audioTraining,
                      onPressed: () => Navigator.pushNamed(context, '/audio'),
                    ),
                  ],
                ),
                SizedBox(height: 20),
                // 第三行：训练记录
                Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    TrainingCard(
                      title: '训练记录',
                      icon: Icons.history,
                      color: AppColors.trainingHistory,
                      onPressed: () => Navigator.push(
                        context,
                        MaterialPageRoute(builder: (context) => TrainingHistoryPage()),
                      ),
                    ),
                  ],
                ),

              ],
            )
          ],
        ),
      ),
    );
  }
}
